package com.celtic.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

import org.appfuse.model.BaseObject;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Indexed;

@Entity
@Indexed
public class Project extends BaseObject implements Serializable{
	
	private static final long serialVersionUID = -1697851573018239440L;
	private Long id;
	private String projectNm;
	private String comment;



	private List<ProjectUrl> projectUrl = new ArrayList<ProjectUrl>();
	
	
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
    @DocumentId
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	@Column(nullable=false, length = 50, unique=true)
	public String getProjectNm() {
		return projectNm;
	}
	public void setProjectNm(String projectNm) {
		this.projectNm = projectNm;
	}
	
	@Column
	public String getComment() {
		return comment;
	}
	public void setComment(String comment) {
		this.comment = comment;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((projectNm == null) ? 0 : projectNm.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Project other = (Project) obj;
		if (projectNm == null) {
			if (other.projectNm != null)
				return false;
		} else if (!projectNm.equals(other.projectNm))
			return false;
		return true;
	}

	
    @OneToMany(fetch=FetchType.EAGER, cascade = CascadeType.ALL,mappedBy="project")    
	public List<ProjectUrl> getProjectUrl() {
		return projectUrl;
	}
	public void setProjectUrl(List<ProjectUrl> projectUrl) {
		this.projectUrl = projectUrl;
	}
	
	@Override
	public String toString() {
		return "Project [id=" + id + ", projectNm=" + projectNm + ", comment="
				+ comment + ", projectUrl=" + projectUrl.toString() + "]";
	}
	
	
	
	


}
